﻿#pragma once

#include "Const.h"

// 格
class Grid {
    public: BOOL mUsed; // 使用则为 TRUE，否则为 FALSE

    /**
     * 构造方法。
     */
    public:Grid(): 
        mUsed(FALSE) {
    }

    /**
     * 构造方法。
     * @param used  使用则为 TRUE，否则为 FALSE
     */
    public: Grid(BOOL used): 
        mUsed(used) {
    }
};

// 带颜色的格
class ColorGrid: public Grid {
    public: COLORREF mColor; // 颜色
    public: ColorGrid::ColorGrid(): 
        mColor(0) {
    }
};

// 方块
class Block {
    // 形状
    protected: enum Shape {
        ONE,    // 形状1
        TWO,    // 形状2
        THREE,  // 形状3
        FOUR    // 形状4
    };

    protected: Grid mBlocks[Const::BLOCK_GRID_COUNT_V][Const::BLOCK_GRID_COUNT_H];  // 方块数据
    protected: COLORREF mColor;     // 颜色
    protected: CDC* mDrawer;        // 绘图者
    protected: CWnd* mGameBoard;    // 游戏区域
    protected: int mLine;           // 当前所在列(左)
    protected: int mRow;            // 当前所在行(上)
    protected: Shape mShape;        // 形状

    public: Block();
    public: virtual ~Block();
    public: void Draw();
    public: void EnterGameboard(CWnd*, CDC*);
    public: virtual void EnterPreview(CDC*);
    protected: virtual void Erase() = 0;
    protected: void EraseRect(RECT*);
    public: virtual int GetBottom() = 0;
    public: virtual int GetTop() = 0;
    protected: virtual void HandleCannotMoveDown() = 0;
    public: virtual BOOL MoveDown();
    public: virtual void MoveLeft();
    public: virtual void MoveRight();
    public: virtual void Transform() = 0;
};
